package net.narusas.aceauction.push.model;

import java.util.*;

import lombok.Data;

@Data
public class Device {
	String id;
	String type;
	String pushToken;
	Integer areaCode;
	String areaCode2;
	String areaCode3;
	String addressEtc;
	String favorite;

	public boolean isIOSDevice() {
		return type != null && "iOS".equals(type);
	}

	public boolean isAndroidSDevice() {
		return type != null && "android".equals(type);
	}

	public boolean isReady() {
		return id != null && pushToken != null && pushToken.equals("") == false;
	}

	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();
		if (id != null) {
			map.put("device_id", id);
		}
		if (type != null) {
			map.put("device_type", type);
		}
		if (pushToken != null) {
			map.put("push_id", pushToken);
		}

		if (areaCode != null && areaCode != 0) {
			map.put("area_code", areaCode);
		}

		if (areaCode2 != null) {
			map.put("area_code2", areaCode2);
		}

		if (areaCode3 != null) {
			map.put("area_code3", areaCode3);
		}

		if (addressEtc != null) {
			map.put("address_etc", addressEtc);
		}
		if (favorite != null) {
			map.put("favorite", favorite);
		}

		return map;
	}
	public boolean isSendable() {
		return areaCode != null && areaCode != 0 && areaCode2 != null;
	}
}
